<%@ page import="cn.yunhe.news.dao.IBoardDao" %>
<%@ page import="cn.yunhe.news.dao.impl.BoardDao" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.yunhe.news.entity.Board" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="cn.yunhe.news.FenYe" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/4/2
  Time: 16:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");

    List<Board> keyList = new ArrayList<Board>();
    String keyword = request.getParameter("keyword");


    String pageI = request.getParameter("pageIndex");
    request.setAttribute("pageIndex",pageI);
    if (pageI == null) {
        pageI = "1";
    }

    int pageIndex = Integer.parseInt(pageI);


    if ("".equals(keyword)||keyword==null) {
        request.getRequestDispatcher("bianjizt.jsp").forward(request,response);
    }



    IBoardDao boardDao = new BoardDao();
    //总条数
    int count=boardDao.keyAll(keyword);
    //总页数
    int pageSize= FenYe.pageSize(count,FenYe.pageNum);

    if (pageIndex < 1) {
        pageIndex = 1;
    }
    if (pageIndex > pageSize) {
        pageIndex = pageSize;
    }

    keyList = boardDao.keywordBoard(FenYe.pageNum,pageIndex,keyword);

    request.setAttribute("keyList", keyList);
    request.setAttribute("keyword",keyword);
    request.getRequestDispatcher("bianjizt.jsp").forward(request, response);
%>
</body>
</html>
